import axios from "axios"
export default {
    namespaced: true,
    state: {
        list: [
            {
                _id: 1,
                name: "张三",
                age: "14",
                gender: "女",
                position: "门店管理员",
                shop: "川大",
                phoneNumber: "12345678900"
            },
            {
                _id: 2,
                name: "李四",
                age: "55",
                gender: "女",
                position: "平台管理员",
                shop: "",
                phoneNumber: "13444444444"
            }

        ],
        findlist1: {}
    },
    getters: {
        finding: function (state, playload) {
            let { type, value } = state.findlist1
            let newarr = state.list
            // 判断搜索条件是否输入
            if (value) {
                return newarr.filter(item => item[type].includes(value))
            }
            return state.list

        }
    },
    mutations: {
        setlist(state, playload) {
            state.list = playload
            console.log(state.list, 8666);
        },

        finders: function (state, playload) {

            state.findlist1 = playload
        },
    },
    actions: {
        // 渲染列表
        getuser: function (context, payload) {
            axios.get("api/userlist/get_administratorList").then(res => {
                console.log(res.data, 343434);

                context.commit('setlist', res.data);
            })
        },
        //    删除列表
        removeuser: function (context, payload) {
            axios.post("api/userlist/delete_administratorList", payload).then(res => {
            })
        },
    }
}